/*
 * Copyright 2010 Christoph Widulle (christoph.widulle@googlemail.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
 * License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */



package com.android1.amarena2d.commons;

public final class IntRectangle {
    
    public int x, y;
    public int width, height;

    /**
     * Constructs a new rectangle with all values set to zero
     */
    public IntRectangle() {

    }

    /**
     * Constructs a new rectangle with the given corner point in
     * the bottom left and dimensions.
     *
     * @param x      The corner point x-coordinate
     * @param y      The corner point y-coordinate
     * @param width  The width
     * @param height The height
     */
    public IntRectangle(int x, int y, int width, int height) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }

    public void set(int x, int y, int width, int height) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }

    public void setEmpty() {
        this.x = 0;
        this.y = 0;
        this.width = 0;
        this.height = 0;
    }

    public boolean isEmpty() {
        return width == 0 && height == 0;
    }


    /**
     * Constructs a rectangle based on the given rectangle
     *
     * @param rect The rectangle
     */
    public IntRectangle(IntRectangle rect) {
        x = rect.x;
        y = rect.y;
        width = rect.width;
        height = rect.height;
    }

    public void set(IntRectangle rect) {
        x = rect.x;
        y = rect.y;
        width = rect.width;
        height = rect.height;
    }

    /**
     * @return the x-coordinate of the bottom left corner
     */
    public int getX() {
        return x;
    }

    /**
     * Sets the x-coordinate of the bottom left corner
     *
     * @param x The x-coordinate
     */
    public void setX(int x) {
        this.x = x;
    }

    /**
     * @return the y-coordinate of the bottom left corner
     */
    public int getY() {
        return y;
    }

    /**
     * Sets the y-coordinate of the bottom left corner
     *
     * @param y The y-coordinate
     */
    public void setY(int y) {
        this.y = y;
    }

    /**
     * @return the width
     */
    public int getWidth() {
        return width;
    }

    /**
     * Sets the width of this rectangle
     *
     * @param width The width
     */
    public void setWidth(int width) {
        this.width = width;
    }

    /**
     * @return the height
     */
    public int getHeight() {
        return height;
    }

    /**
     * Sets the height of this rectangle
     *
     * @param height The height
     */
    public void setHeight(int height) {
        this.height = height;
    }
}

